Cache

Why does a CPU have a Cache?

Because there is something called the memory bottleneck which means the CPU can handle much more instructions that can be read from memory. This means we need some way of increasing performance. Using SRAM in the CPU greatly reduced the amount of time to get data from memory. This is because the cache sorts chunks of memory that are likely to be accessed by the CPU. Such a case is called a cache hit. We want cache hits because of the improved performance. Because memory tends to be stored in a contiguous manner -- one address after the other. We store chunks instead of individual memory addresses. This leads to more cache hits on average.

Different kinds of caches

There is a saying in Computer Science: everything that stores information is a cache! This also means there are many different kinds of caches in hardware. For instance, a typical L1 cache may be broken up into data and instruction caches to store their respective contents.

There is also cache used for replaced blocks of memory called a victim cache. It basically gives the memory a second chance to be access in the near future to cut down on mm accesses.

A Trace cache is used to store decoded instructions. This cache can be accessed in the future so that the control unit doesn't need to decode the instructions again.